package com.example.studyllm.controller.rag;


import com.example.studyllm.dto.validate.Add;
import com.example.studyllm.dto.validate.Update;
import com.example.studyllm.entity.rag.RagKnowledge;
import com.example.studyllm.service.rag.RagKnowledgeService;
import com.example.studyllm.vo.base.PageResultVO;
import com.example.studyllm.vo.base.Result;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author kw
 * @since 2025-02-05 15:12:48.825120
 */
@RestController
@RequestMapping("/ragKnowledge")
public class RagKnowledgeController {

    @Resource
    private RagKnowledgeService ragKnowledgeService;

    /**
     * 通过id查询
     */
    @GetMapping("/{id}")
    public Result<RagKnowledge> getById(@PathVariable(value = "id") Integer id) {
        return Result.success(ragKnowledgeService.getById(id));
    }

    /**
     * 新增
     */
    @PostMapping("/")
    public Result save(@RequestBody RagKnowledge ragKnowledge) {
        return Result.success(ragKnowledgeService.addRagKnowledge(ragKnowledge));
    }

    /**
     * 通过id删除
     */
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable(value = "id") String ids) {
        ragKnowledgeService.deleteByIds(ids);
        return Result.success();
    }

    /**
     * 修改
     */
    @PutMapping("/")
    public Result updateById(@RequestBody RagKnowledge ragKnowledge) {
        return Result.success(ragKnowledgeService.updateRagKnowledgeById(ragKnowledge));
    }

    /**
     * 分页查询
     */
    @GetMapping("/")
    public Result<PageResultVO<RagKnowledge>> page(RagKnowledge ragKnowledge) {
        return Result.success(ragKnowledgeService.getPage(ragKnowledge));
    }

}